<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=renderer content=webkit><meta name=keywords content=集什商城,集什,得力,采购,办公用品,办公家具,家用电器,采购网,得力文具,办公设备,得力集团,办公耗材,办公用品批发,办公家具采购><meta name=description content=集什商城,专业的政企采购平台,倡导简单、阳光、高效的采购模式。集什商城通过互联网大数据基础及专属营销解决方案，围绕办公用品、工业品、企业定制、节庆福利、积分兑换、弱电系统集成、扶贫公益七大用户场景化的产品需求展开品类构建，为政企提供平台开发、产品供应、电商运营、物流配送及售后服务整体解决方案。>
    <title>集什商城-政企采购专业电商平台,一站式采购服务商城</title>
    <link rel="stylesheet" href="./css/base1.css">
    <link rel="stylesheet" href="./css/view.css">
</head>
<body>
    <div class="header-h">
        <div class="header">
            <h1 class="logo">
                <a href="">集什商城</a>
            </h1>
        </div>
    </div>
    <div class="banner">
        <img src="./imgs/banner-1.jpg" alt="">
        <div class="sign">
            <ul class="first">
                <li class="first-ulf con">
                    <i class="uli-f ">账号登录</i>
                    <div class="da">
                    <div class="mima">
                        <div class="account-f ment">
                            <div class="user">
                                <span>用户名</span>
                                <input class="user-ipt" type="text" value="用户名/邮箱/手机号">
                            </div>
                            <div class="password">
                                <span>密码</span>
                                <input class="password-ipt" type="text" value="请输入密码">
                            </div>
                            <div class="check">
                                <form action="" class="one">
                                    <input type="checkbox" id="e">
                                    <label for="e" class="d">记住我的账号</label>
                                </form>
                                <p class="forget">忘记密码</p>
                            </div>
                            <button class="sign-but">登录</button>
                            <p class="phone-yan phone-deng">手机验证码登录</p>
                        </div>
                    </div>
                    <div class="phone">
                        <div class="phone">
                            <div class="account-f ment">
                                <div class="user">
                                    <span>手机号</span>
                                    <input class="user-ipt" type="text" value="请输入手机号">
                                </div>
                                <div class="password">
                                    <span>手机验证码</span>
                                    <input class="password-ipt" type="text" value="验证码">
                                    <i>获取验证码</i>
                                </div>
                                <button class="sign-but">登录</button>
                                <p class="phone-yan mima-deng">密码登录</p>
                            </div>
                        </div>
                    </div>
                    </div>
                </li>
                <li class="first-uls">
                    <i class="uli-s">扫码登录</i>
                    <div class="saoma">
                        <div class="account-s">
                            <div class="hezi">
                                <p class="saoma-p1">
                                    <b class="iconfont">&#xeb81;</b>
                                    <i>打开</i>
                                    <span>手机集什APP</span>
                                </p>
                                <p class="saoma-p2">扫一扫登录</p>
                                <div class="saoma-p3"></div>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
        <div class="ebend">
            <div class="b-end">
                <div class="bend"><span>友情链接：</span>
                    <ul class="bend-ul">
                        <li class="bend-lis"><a href="">得力剧团</a></li>
                        <li class="bend-lis"><a href="">得力商城</a></li>
                        <li class="bend-lis"><a href="">集什商城</a></li>
                        <li class="bend-lis"><a href="">企业采购</a></li>
                        <li class="bend-lis"><a href="">办公采购网</a></li>
                        <li class="bend-lis"><a href="">企业办公采购</a></li>
                        <li class="bend-lis"><a href="">办公用品</a></li>
                        <li class="bend-lis"><a href="">办公用品采购</a></li>
                        <li class="bend-lis"><a href="">办公文具采购</a></li>
                        <li class="bend-lis"><a href="">企业办公文具用品</a></li>
                        <li class="bend-lis"><a href="">企业办公采购网</a></li>
                    </ul>
                </div>
                
                <ul class="lend">
                    <li class="lend-li"><a href="">Copyright&nbsp;&copy;&nbsp;2014-2020</a></li>
                    <li class="lend-li"><a href="">集什商城版权所有</a></li>
                    <li class="lend-li">浙ICP备18053989号-1<a href=""></a></li>
                    <li class="lend-li"><a href="">浙公网安备&nbsp;33010402003862号</a></li>
                </ul>
                <br>
                
                <ul class="tend">
                    <li><img src="./imgs/001.jpg" alt=""></li>
                    <li><img src="./imgs/002.jpg" alt=""></li>
                    <li><img src="./imgs/003.jpg" alt=""></li>
                    <li><img src="./imgs/004.jpg" alt=""></li>
                    <li><img src="./imgs/005.jpg" alt=""></li>
                </ul>
            </div>    
        </div>

<script src="./js/view.js"></script>
<script src="./js/jquery2.2.4.js"></script>
<script>
const osubmit = document.querySelector(".sign-but");
const otel = document.querySelector(".user-ipt");
const opassword = document.querySelector(".password-ipt");


osubmit.onclick = function(){
    ajax("http://localhost:3000/api",function(res){

        console.log(res);
        res = JSON.parse(res);

        if(res.code === 0){
            alert("用户名不存在，请先注册");
            location.href = "./register.html";
        }else if(res.code === 1){
            // 登录成功之后，将登录成功信息，存到本地存储，方便其他功能或页面使用
            localStorage.setItem("isLogin","ok");
            localStorage.setItem("username",res.data);

            if(confirm("登录成功，是否跳转到首页")){
                location.href = "./homePage.html";
            }
        }else if(res.code === 2){
            alert("密码不符，请重新输入");
            opassword.value = "";
            opassword.focus();
        }
    },{
        type:"login",
        username:otel.value,
        password:opassword.value
    })
}



function ajax(url, callback, data){
    let str = "";
    for(let i in data){
        str += `${i}=${data[i]}&`
    }
    url += "?" + str;
    const xhr = new XMLHttpRequest();
    xhr.open("get",url)
    xhr.onload = function(){
        if(xhr.status === 200){
            callback(xhr.responseText)
        }
    }
    xhr.send();
}

</script>
</body>
</html>